<?php
include_once("../configure/admin.config.inc.php");	//--> admin global var
include_once("db.inc.php");							//--> db global var
include_once("Smarty.class.php");					//--> out template
include_once("Operation.php");						//--> Operation
include_once("Manufacturer.php");					//--> Manufacturer
require_once("controlHeader.php");					//--> system control header

$objOperate 		= new Operation($objSession->getLanguage());			//--> Operation
$objManufacturer	= new Manufacturer(DB_TAG_SYSTEM, $uid);					//--> Manufacturer

$error_message 	= '';
$strName 		= '';
$url 			= '';
$summary 		= '';

$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(isset($_POST['Submit'])){
	$name 	= $_POST['name'];
	$url 	= $_POST['url'];
 	
	if(empty($name)){
		$error_message = 'The manufacturer name should\'t be empty.';
	}else if($objManufacturer->IsExistName($LANGEUAGE_ID, $name)){
		$error_message = 'the manufacturer name be existed.';
	}else{
		$isReturnOrg = $objManufacturer->add($arrOperate, $LANGEUAGE_ID, $name, $url);
		if($isReturnOrg)
			$error_message = 'add successfully.';
		else{
			$error_message = 'add failure.';
		}
	}
}


 
/*----- out html -----*/
$smarty = new Smarty();		//----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir  = COMPILE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);

$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);

$smarty->assign('name', $name);
$smarty->assign('url', $url);


$smarty->display('listManufacturer_Add.htm');
?>
